package cn.ywang.mybatis.old;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author BeatificWang
 * @date 2019/9/2 22:41
 */
public class MapperProxy implements InvocationHandler {

	private SqlSession sqlSession;

	public MapperProxy(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		String statementId = method.getDeclaringClass().getName() + "." + method.getName();
		return this.sqlSession.selectOne(statementId, args[0]);
	}
}
